<?php
/**
 * Geocontexter
 * @link http://code.google.com/p/geocontexter/
 * @package Geocontexter
 */

/**
 * Admin index controller
 *
 *
 * @package Geocontexter
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @author Armand Turpel <geocontexter@gmail.com>
 * @version $Rev$ / $LastChangedDate$ / $LastChangedBy$
 */

namespace Youobserve\Controller;

use Zend\View\Model\JsonModel;
use Youobserve\Controller\AbstractJsonController;


class TaxonSearchController extends AbstractJsonController
{

    protected function init($controller)
    {

    }

    public function indexAction()
    {
        $term = $this->params()->fromQuery('term',false);

        $ItemSearch = $this->CoreModel('ItemSearch', 'Youobserve');

        $params  = array('search' => $term,
                         'limit'  => array(20,1));

        try {

          $result  = $ItemSearch->run( $params );
//die(var_export($result,true));
          return new JsonModel($result);

        } catch (\Exception $e) {

          $this->default_error = "Error\n File: " . __file__ . "\nLine: " . __line__ . "\nError: " . $e->getErrorString();
die(var_export($this->default_error,true));
          return new JsonModel(array('error' => $this->default_error));

        }
    }
}
